import React, { Component, createRef } from 'react'
import Test from './Test'
import ReactDOM from 'react-dom'

export default class App extends Component {
  state = {
    age: 18,
    bBar: true
  }

  render () {
    return (
      <div>
        App
        <button onClick={() => this.setState({ bBar: !this.state.bBar })}>卸载Test</button>
        <button
          onClick={() => {
            ReactDOM.unmountComponentAtNode(document.getElementById('react'))
          }}
        >
          另一种触发卸载的方式
        </button>
        <hr />
        {this.state.bBar && <Test />}
      </div >
    )
  }

  componentDidUpdate () {
    // console.log('2，componentDidUpdate')
    // console.log(document.querySelector('span').innerHTML)
  }
}
